package springbook.user.dao;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * DB connection을 카운트 하기 위해 만든 클래스
 * 
 * */
public class CountingConnectionMaker implements ConnectionMaker {
	int counter = 0;
	
	private ConnectionMaker realConnectionMaker;
	
	//생성자
	public CountingConnectionMaker(ConnectionMaker realConnectionMaker) {
		this.realConnectionMaker = realConnectionMaker;
	}

	public Connection makeConnection() throws ClassNotFoundException,
			SQLException {
		this.counter++;
		return realConnectionMaker.makeConnection();
	}
	
	public int getCounter(){
		return this.counter;
	}

}
